package com.bw.user.task;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bw.core.result.ResponseResult;
import com.bw.user.service.TbIdentityAuthService;
import io.swagger.models.auth.In;
import org.springframework.web.multipart.MultipartFile;

import java.util.concurrent.Callable;

public class LiveAuthTask implements Callable<Boolean> {

    private MultipartFile livePic;
    private TbIdentityAuthService identityAuthService;

    public LiveAuthTask(MultipartFile livePic, TbIdentityAuthService identityAuthService) {
        this.livePic = livePic;
        this.identityAuthService = identityAuthService;
    }

    @Override
    public Boolean call() throws Exception {

        boolean flag=false;
        String livingauthen = identityAuthService.livingauthen(livePic);
        System.out.println("身份证结果："+livingauthen);
        JSONObject json = JSON.parseObject(String.valueOf(livingauthen));
        Integer code =json.getInteger("code");//代表成功

        if (code==0){
            JSONObject data = json.getJSONObject("data");
            Integer score = json.getInteger("score");

            if (score>75){
                flag= true;
            }

        }
        return flag=false;
    }
}
